<?php
	header("Content-type: text/html;charset=utf8");
	require_once("../db/dbclass.php");
	require_once("../model/userinfo.php");
	require_once("../utils/common.php");
	$myDb=&DbController::getInstance();
	$user_id=$_POST['user_id'];
	$user_content=$_POST['tweets_content'];
	$myImg=new UpdateUserInfo();
	getFile("uploadedfile",$user_id,$myImg,2);
	if($myImg==TRUE){
		$param="INSERT INTO yj_tweets (user_id,tweets_time,tweets_content,tweets_img) VALUES ('".$user_id."','".date('y-m-d h:i:s',time())."','".$user_content."','".$myImg->img_url."')";
		$result=$myDb->exec_query($param);
		if($result==TRUE){
			$result='{"result":"success"}';
		}else{
			$result='{"result":"failure"}';
		}
	}
	//敏感词处理
	$param="select * from yj_tweets where user_id='".$user_id."' and tweets_content='".$user_content."'";
	$result=$myDb->exec_query($param);
	while ($row = mysqli_fetch_array($result,MYSQL_ASSOC)){
		sensitivity_words_test($row['tweets_id'],$myDb,$user_content);
	}
	json_encode($result);
	echo $result;
?>